<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\ProductCategory;
use App\Transformers\ProductCategoryTransformer;

class ProductCategoryController extends Controller
{
    /**
     * 查询餐馆的商品分类
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request) {
        $bistro_id = $request->input('bistro_id');
        $product_categories = ProductCategory::where('bistro_id', $bistro_id)->paginate(10);
        $data['data'] = [
            'product_categories' => $this->factalPaginator($product_categories, new ProductCategoryTransformer())
        ];
        return $this->apiSuccess($data);
    }

}
